import java.util.*;

public class Main {

    //
    public static void main1(String[] args){
        Scanner in = new Scanner(System.in);
        int n = in.nextInt(), m = in.nextInt();
        double ret = 1.0;

        for(int i = n; i >= n - m + 1; i--) { ret *= i;}
        for(int i = m; i >= 2; i--) { ret /= i;}
        for(int i = 0; i < m; i++) { ret *= 0.8;}
        for(int i = 0; i  < n - m; i++) { ret *= 0.2;}
        System.out.printf("%.4f", ret);
    }

    //
    public static int n, l, r;
    public static int[] arr;

    public static long find(int x){
        int left = 0, right = 0;

        long ret = 0;
        while(right < n){
            while(arr[right] - arr[left] > x) { left++;}
            ret += right - left;
            right++;
        }
        return ret;
    }

    public static void main2(String[] args){
        Scanner in = new Scanner(System.in);
        n = in.nextInt(); l = in.nextInt(); r = in.nextInt();
        arr = new int[n];
        for(int i = 0; i < n; i++) { arr[i] = in.nextInt();}
        Arrays.sort(arr);

        System.out.println(find(r) - find(l - 1));
    }

    //
    public static void main3(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int x = 1, y = 2;
        int MOD = 1000000007;

        for(int i = 2; i <= n; i++){
            int xx = x, yy = y;
            x = (yy * 2 + 1) % MOD;
            y = ((yy * 2 + 2) % MOD + xx) % MOD;
        }
        System.out.println(x + " " + y);
    }

    //
//    public static int n;
    public static int path;  //记录路径里面所有元素的和
    public static int ret = 0x3f3f3f3f;  //记录最终结果
    public static boolean[] use = new boolean[1010];  //记录路径里面选择的元素
//    public static int[] arr;

    public static boolean isPrim(int x){
        if(x <= 1) { return false;}
        for(int i = 2; i <= Math.sqrt(x); i++){
            if(x % i == 0) { return false;}
        }
        return true;
    }

    public static void dfs(int pos){
        if(pos == n){
            ret = Math.min(ret, path);
            return ;
        }

        for(int i = 2; i <= arr[pos]; i++){
            if(arr[pos] % i == 0 && !use[i] && isPrim(i)){
                path += i;
                use[i] = true;
                dfs(pos + 1);
                //恢复现场
                path -= i;
                use[i] = false;
            }
        }
    }

    public static void main4(String[] args) {
        Scanner in = new Scanner(System.in);
        n = in.nextInt();
        arr = new int[n];
        for(int i = 0; i < n; i++){
            arr[i] = in.nextInt();
        }

        dfs(0);
        System.out.println(ret == 0x3f3f3f3f ? -1 : ret);
    }

    //
    public static void main5(String[] args){
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        char[] s = in.next().toCharArray();

        //dp[i] 表示: 长度为 i 的所有的子序列中,最小的末尾是多少
        char[] dp = new char[n + 1];
        int ret = 0;

        for(int i = 0; i < n; i++){
            char ch = s[i];
            //把 ch 放在什么位置上
            if(ret == 0 || ch >= dp[ret]){
                dp[++ret] = ch;
            }else{
                int left = 1, right = ret;
                while(left < right){
                    //二分出 ch 的插入位置
                    int mid = (left + right) / 2;
                    if(dp[mid] > ch){
                        right = mid;
                    }else{
                        left = mid + 1;
                    }
                }
                dp[left] = ch;
            }
        }
        System.out.println(n - ret);
    }
}
